package it.sources.untile;

import lombok.Data;
@Data
public class R {
        private boolean success = true;

        private String message = "成功";

        //错误码，用来描述错误类型 ，1000 表示么有错误
        private String code = "1000";

        //返回的数据
        private Object data;

        /** 创建当前实例 **/
        public static  R success(){
            return new  R();
        }
        /** 创建当前实例 **/
        public static  R success(Object obj){
             R instance = new  R();
            instance.setData(obj);
            return instance;
        }

        public static  R success(Object obj, String code){
             R instance = new  R();
            instance.setCode(code);
            instance.setData(obj);
            return instance;
        }
        /** 创建当前实例 **/

        public static  R error(String message, String code){
             R instance = new  R();
            instance.setMessage(message);
            instance.setSuccess(false);
            instance.setCode(code);
            return instance;
        }

        public static  R error(){
             R  r = new  R();
             r.setSuccess(false);
            return  r;
        }

        /** 创建当前实例 **/
        public static  R error(String message){
            return error(message,null);
        }
    }

